<template>
  <div style="max-width: 640px" v-bind:class="{ 'app-center': isCenter }">
    <router-view />
  </div>
</template>


<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      isCenter: false,
    };
  },
  created() {
    request
      .get("/info")
      .then((response) => {
        console.log(response);
      })
      .catch((error) => {
        console.error(error);
      });

    console.log(process.env.NODE_ENV);
    if (document.body.clientWidth > 640) {
      this.isCenter = true;
    }
  },
  mounted() {
    // 监听窗口大小
    window.onresize = () => {
      return (() => {
        if (document.body.clientWidth > 640) {
          this.isCenter = true;
        }
      })();
    };
  },
};
</script>

<style>
.app-center {
  margin: 0 auto;
}
</style>
